﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text.Json;

namespace JuCheap.Core.WebApi.Controllers
{
    /// <summary>
    /// 模拟数据
    /// </summary>
    [ApiController]
    [Route("api")]
    public class MockDataController : ControllerBase
    {
        /// <summary>
        /// 项目数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("list/search/projects")]
        public ActionResult GetProjects()
        {
            var projects = new[]
            {
                new {
                  id= 1,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png",
                  title= "Alipay",
                  description= "那是一种内在的东西， 他们到达不了，也无法触及的",
                  status= 1,
                  updatedAt= "2018-07-26 "
                },
                new {
                  id= 2,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png",
                  title= "Angular",
                  description= "希望是一个好东西，也许是最好的，好东西是不会消亡的",
                  status= 1,
                  updatedAt= "2018-07-26 "
                },
                new {
                  id= 3,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png",
                  title= "Ant Design",
                  description= "城镇中有那么多的酒馆，她却偏偏走进了我的酒馆",
                  status= 1,
                  updatedAt= "2018-07-26 "
                },
                new {
                  id= 4,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png",
                  title= "Ant Design Pro",
                  description= "那时候我只会想自己想要什么，从不想自己拥有什么",
                  status= 1,
                  updatedAt= "2018-07-26 "
                },
                new {
                  id= 5,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png",
                  title= "Bootstrap",
                  description= "凛冬将至",
                  status= 1,
                  updatedAt= "2018-07-26 "
                },
                new {
                  id= 6,
                  cover= "https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png",
                  title= "Vue",
                  description= "生命就像一盒巧克力，结果往往出人意料",
                  status= 1,
                  updatedAt= "2018-07-26 "
                }
            };

            return Ok(new { data = projects });
        }

        /// <summary>
        /// 活动数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("workplace/activity")]
        public ActionResult GetActivities()
        {
            var activities = new[] {
                new {
                    id = 1,
                    user = new
                    {
                        nickname= "@name",
                        avatar= "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
                    },
                    project = new
                    {
                        name= "开发组",
                        action= "更新",
                        Event= "番组计划"
                    },
                    time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  },
                  new {
                    id = 1,
                    user=new {
                      nickname= "蓝莓酱",
                      avatar= "https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png"
                    },
                    project=new {
                      name= "开发组",
                      action= "更新",
                      Event= "番组计划"
                    },
                    time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  },
                  new {
                    id= 1,
                    user=new {
                      nickname= "@name",
                      avatar= "@image(64x64)"
                    },
                    project=new {
                      name= "开发组",
                      action= "创建",
                      Event= "番组计划"
                    },
                    time= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  },
                  new {
                    id= 1,
                    user=new {
                      nickname= "独孤九",
                      avatar= "@image(64x64)"
                    },
                    project=new {
                      name= "设计天团",
                      action= "更新",
                      Event= "六月迭代"
                    },
                    time= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  },
                  new {
                    id= 1,
                    user=new {
                      nickname= "@name",
                      avatar= "@image(64x64)"
                    },
                    project=new {
                      name= "设计天团",
                      action= "created",
                      Event= "六月迭代"
                    },
                    time= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  },
                  new {
                    id= 1,
                    user=new {
                      nickname= "张天师",
                      avatar= "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
                    },
                    project=new {
                      name= "设计天团",
                      action= "created",
                      Event= "六月迭代"
                    },
                    time= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                  }
            };

            return Ok(activities);
        }

        /// <summary>
        /// 团队数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("workplace/teams")]
        public ActionResult GetTeams()
        {
            var teams = new[]
            {
                new {
                    id= 1,
                    name= "钢筋组",
                    avatar= "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png"
                },
                new {
                    id= 2,
                    name= "混泥土组",
                    avatar= "https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png"
                },
                new {
                    id= 3,
                    name= "第几组",
                    avatar= "https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png"
                },
                new {
                    id= 4,
                    name= "挖掘机",
                    avatar= "https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png"
                },
                new {
                    id= 5,
                    name= "蓝翔队",
                    avatar= "https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png"
                }
            };

            return Ok(teams);
        }

        /// <summary>
        /// 服务数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("service")]
        public ActionResult GetServices()
        {
            var services = new dynamic[10];
            for (var i = 1; i <= 10; i++)
            {
                services[i - 1] = new
                {
                    key = i,
                    id = i,
                    no = "No " + i,
                    description = "一个不可告人的密码",
                    callNo = i,
                    status = 0,
                    updatedAt = DateTime.Now,
                    editable = false
                };
            }
            var pageResult = new
            {
                data = services,
                pageNo = Request.Query["pageNo"],
                totalCount = 120
            };

            return Ok(pageResult);
        }

        /// <summary>
        /// 角色
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("role")]
        public ActionResult GetRoles()
        {
            var services = new dynamic[10];
            for (var i = 1; i <= 10; i++)
            {
                services[i - 1] = new
                {
                    key = i,
                    id = i,
                    no = "No " + i,
                    name = "李" + i,
                    description = "张天师的日常活动",
                    callNo = i,
                    status = 1,
                    updatedAt = DateTime.Now,
                    editable = false
                };
            }
            var pageResult = new
            {
                data = services,
                pageNo = Request.Query["pageNo"],
                totalCount = 120
            };

            return Ok(pageResult);
        }

        /// <summary>
        /// 权限列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("permission")]
        public ActionResult GetPermissions()
        {
            var services = new dynamic[10];
            for (var i = 1; i <= 10; i++)
            {
                services[i - 1] = new
                {
                    key = i,
                    id = i,
                    no = "No " + i,
                    name = "权限" + i,
                    description = "系统设置",
                    callNo = i,
                    status = 1,
                    updatedAt = DateTime.Now,
                    actionData = JsonSerializer.Serialize(new[]
                    {
                        new {value="add", label="添加", describe="添加"},
                        new {value="edit", label="编辑", describe="编辑"},
                        new {value="del", label="删除", describe="删除"},
                        new {value="view", label="查看", describe="查看"}
                    })
                };
            }
            var pageResult = new
            {
                data = services,
                pageNo = Request.Query["pageNo"],
                totalCount = 120
            };

            return Ok(pageResult);
        }

        /// <summary>
        /// 雷达图数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("workplace/radar")]
        public ActionResult GetRadars()
        {
            var radars = new Dictionary<string, object>[]
            {
                new Dictionary<string, object>{
                    { "item", "引用"  },
                    { "个人", 70 },
                    { "团队", 30 },
                    { "部门", 40 }
                  },
                  new Dictionary<string, object>{
                    { "item", "口碑"},
                    { "个人", 60 },
                    { "团队", 70},
                    { "部门", 40}
                  },
                  new Dictionary<string, object>{
                    { "item", "产量"},
                    { "个人", 30 },
                    { "团队", 70},
                    { "部门", 40}
                  },
                  new Dictionary<string, object>{
                     { "item", "贡献"},
                    { "个人", 30 },
                    { "团队", 70},
                    { "部门", 40}
                  },
                  new Dictionary<string, object>{
                    { "item", "热度"},
                    { "个人", 30 },
                    { "团队", 70},
                    { "部门", 40}
                  },
                  new Dictionary<string, object>{
                    { "item", "引用"},
                    { "个人", 30 },
                    { "团队", 70},
                    { "部门", 40}
                  }
            };

            return Ok(radars);
        }

        /// <summary>
        /// 文章列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("list/article")]
        public ActionResult GetArticles()
        {
            var titles = new[]
            {
                "Alipay",
                "Angular",
                "Ant Design",
                "Ant Design Pro",
                "Bootstrap",
                "React",
                "Vue",
                "Webpack"
            };

            var avatar = new[]{
                "https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png",
                "https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png",
                "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png",
                "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png",
                "https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png",
                "https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png",
                "https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png",
                "https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png",
            };

            var covers = new[] {
              "https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png",
              "https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png",
              "https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png",
              "https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png",
              "https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png",
              "https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png",
              "https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png",
              "https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png"
            };

            var owner = new[] {
              "王大虎",
              "吴嘉鑫",
              "李嘉欣",
              "李斌",
              "曲丽丽",
              "周笔畅",
              "李长春",
              "历史书",
              "看看就"
            };

            var list = new dynamic[8];
            for (var i = 0; i < 8; i++)
            {
                list[i] = new
                {
                    id = Guid.NewGuid().GetHashCode(),
                    avatar = avatar[i],
                    owner = owner[i],
                    content = titles[i],
                    star = new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999),
                    percent = new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999),
                    like = new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999),
                    message = new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999),
                    description = "测试",
                    href = "#",
                    title = titles[i],
                    updatedAt = DateTime.Now.ToString(),
                    members = new[]{
                        new {
                            avatar= "https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png",
                            name= "曲非音",
                            id= "member1"
                        },
                        new {
                            avatar= "https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png",
                            name= "王昭君",
                            id= "member2"
                        },
                        new {
                            avatar= "https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png",
                            name= "董娜娜",
                            id= "member3"
                        }
                    },
                    activeUser = new Random(Guid.NewGuid().GetHashCode()).Next(10000, 39999),
                    newUser = new Random(Guid.NewGuid().GetHashCode()).Next(1000, 9999),
                    cover = covers[i]
                };
            }

            return Ok(list);
        }
    }
}
